<template>
    <section>
        <!--工具条-->
        <div class="searchgrid">
            <div style="float: right;">
                <input v-model="post_data.search.cust_id" style="width:120px;height:20px;"
                       value="" maxlength="10" type="text" placeholder="搜索:客户ID">
                <input v-model="post_data.search.stock_finance_id" style="width:120px;height:20px;"
                       value="" maxlength="10" type="text" placeholder="搜索:配资ID">
              <input class="yl-input-button" value=" 查询 " type="button" v-on:click="search">
            </div>

        </div>
        <!--列表-->
        <el-table :data="forms.list"
                  highlight-current-row
                  v-loading="loading"
                  style="width: 100%;">

            <el-table-column label="代理商ID" prop="agent_id" show-overflow-tooltip></el-table-column>
            <el-table-column label="客户信息" prop="client.cust_info" min-width="120px" show-overflow-tooltip></el-table-column>
            <el-table-column label="配资ID" prop="stock_finance_id" show-overflow-tooltip></el-table-column>
            <el-table-column label="业务类型" prop="interest_type" show-overflow-tooltip></el-table-column>
            <el-table-column label="产品名称" prop="u_stock_financing.stock_finance_product.product_name" show-overflow-tooltip></el-table-column>
            <el-table-column label="借款金额" prop="u_stock_financing.current_finance_amount" show-overflow-tooltip></el-table-column>
            <el-table-column label="保证金" prop="u_stock_financing.total_caution" show-overflow-tooltip></el-table-column>
            <el-table-column label="借款利率" prop="u_stock_financing.stock_finance_product.interests_rate" show-overflow-tooltip></el-table-column>
            <el-table-column label="递延费金额" prop="total_insterests" show-overflow-tooltip></el-table-column>
            <el-table-column label="账户余额" prop="account_left" show-overflow-tooltip></el-table-column>
            <el-table-column label="收费说明" v-if="isUserSystemAdmin" prop="remark" show-overflow-tooltip></el-table-column>
            <el-table-column v-if="forms.props.agent_level<2" label="一级代理营收" prop="agent1_interests" show-overflow-tooltip></el-table-column>
            <el-table-column v-if="forms.props.agent_level<3" label="二级代理营收" prop="agent2_interests" show-overflow-tooltip></el-table-column>
            <el-table-column v-if="forms.props.agent_level<4" label="三级代理营收" prop="agent3_interests" show-overflow-tooltip></el-table-column>
            <el-table-column v-if="forms.props.agent_level<5" label="四级代理营收" prop="agent4_interests" show-overflow-tooltip></el-table-column>
            <el-table-column v-if="forms.props.agent_level<6" label="五级代理营收" prop="agent5_interests" show-overflow-tooltip></el-table-column>
            <el-table-column label="已缴纳金额" prop="paid_amount" show-overflow-tooltip></el-table-column>
            <el-table-column label="客户推广成本" prop="cust_promotion_cost" show-overflow-tooltip></el-table-column>
            <el-table-column label="收费时间" prop="created_time" min-width="130" show-overflow-tooltip></el-table-column>
            <el-table-column label="状态" prop="is_paid_over" show-overflow-tooltip></el-table-column>
        </el-table>

        <!--工具条-->
        <div class="pagination">
            <el-col :span="24" class="toolbar">
                <el-pagination
                        @size-change="changeSize"
                        @current-change="pageChange"
                        :current-page="post_data.offset/post_data.limit+1"
                        :page-sizes="[15, 30, 45, 60]"
                        :page-size="post_data.limit"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="forms.count"
                        style="float:left;">
                </el-pagination>
            </el-col>
        </div>
    </section>
</template>


<script type="text/ecmascript-6">
    import {getUStockFinanceInterestPercentages} from '../../../api/stock';
    export default {
        data() {
            return {
                loading: false,
                forms: {props: {agent_level: ''}},
                dialog1Visible: false,
                post_data: {
                    field: ['id', 'cust_id', 'stock_finance_id', 'interest_type', 'total_insterests', 'account_left', 'agent1_interests',
                        'agent2_interests', 'agent3_interests', 'agent4_interests', 'agent5_interests', 'paid_amount',
                        'cust1_interests', 'cust2_interests', 'cust3_interests', 'remark', 'created_time', 'is_paid_over', '"" as cust_promotion_cost'
                    ],
                    search: {
                        cust_id: '',
                        stock_finance_id: ''
                    },
                    where: {
                        status: ''
                    },
                    count: true,
                    offset: 0,
                    limit: 15,
                    u_stock_financing: {
                        field: ['id', 'product_id', 'init_caution_money', 'post_finance_caution_money',
                            'post_add_caution_money', '"" as total_caution', 'current_finance_amount'],
                        stock_finance_product: {
                            field: ['id', 'product_name', 'interests_rate']
                        }
                    },
                    client: {
                        field: ['id', 'nick_name', 'cellphone', '"" as cust_info']
                    },
                    order: 'id desc'
                }
            }
        },
        created(){
            this.getList();
        },
        methods: {
            getList: function () {
                this.loading = true;
                getUStockFinanceInterestPercentages(this.post_data).then(res => {
                    this.loading = false;
                    if (res.status === 0) return this.ezNotifyAxiosThen(res);
                    this.forms = res.data;
                }).catch(error => this.ezNotifyAxiosCatch(error));
            },
            pageChange: function (index) {
                this.post_data.offset = (index - 1) * this.post_data.limit;
                this.getList();
            },
            changeSize: function (num) {
                this.post_data.offset = 0;
                this.post_data.limit = num;
                this.getList();
            },
            search: function () {
                this.post_data.offset = 0;
                this.getList();
            },
            changeSelect: function (value) {
                this.post_data.offset = 0;
                this.getList();
            }
        }
    }
</script>

<style scoped>
</style>
